<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>个人中心</title>
		<meta name="Description" content="" />
		<meta name="Keywords" content="" />
		<meta name="format-detection" content="telephone=no, email=no" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<!-- 忽略页面中的数字识别为电话，忽略email识别 -->
		<meta name="applicable-device" content="mobile" />
		<meta name="apple-mobile-web-app-title" content="" />
		<!-- 添加到主屏后的标题（iOS 6 新增） -->
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!-- 是否启用 WebApp 全屏模式 -->
		<meta name="HandheldFriendly" content="true" />
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="author" content="Jack" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../../js/flexible.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/jquery-weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/icon_font/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../../style/car.css" />
		<link rel="stylesheet" type="text/css" href="../../style/pub_foot.css" />
		<style type="text/css">
			.website-margin-bottom {
				margin-bottom: 75px;
			}
		</style>
	</head>

	<body>
		<div class="">
			<div class="my-site-icon">
				<a href="out_login.html"><i class="iconfont icon-weibiaoti-_huaban"></i></a>
			</div>
			<div class="website-margin-bottom">
				<div class="my-center">
					<div class="my-info-flex">
						<div class="header-right" onclick="main_obj.compile_fn()"><img src="../../images/header.png" class="tacitly" style="object-fit: cover;" /></div>
						<div>
							<div onclick="main_obj.compile_fn()">
								<div>
									<span class="welcome"></span>
									<span class="is-serves"></span>
								</div>
								<div class="look-datum">查看并编辑个人资料</div>
							</div>

							<div id="is_show_btn" style="display: none;">
								<button class="login-btn" onclick="main_obj.login_fn()">登录/注册</button>
							</div>
						</div>
					</div>

					<div class="wallet-top wallet-top-border">
						<div class="my-wallet">
							<div class="wallet-font">我的钱包</div>
							<div class="wallet-flex">
								<a href="javascript:;" class="money-flex" onclick="main_obj.money_detail()">
									<div class="sum" id="sum">0</div>
									<div class="sum-yuan">我的收入（元）</div>
								</a>
								<a href="javascript:;" class="money-flex money-lin money-border" onclick="main_obj.withdraw()">
									<span class="withdraw">提现</span>
								</a>
								<a href="javascript:;" class="money-flex money-lin" onclick="main_obj.sr_detail()">
									<span class="withdraw">收入记录</span>
								</a>
							</div>
						</div>

					</div>

					<!-- <div class="wallet-top wallet-top-border" id="apply-group" style="display: none;">
						<div class="my-wallet">
							<div class="wallet-font">进入系统小组</div>
							<div class="admin-top">
								<div class="admin-item">
									<span class="share-inner">分享人：</span><input type="text" class="share-input" id="share-pople"/>
								</div>
								<div class="admin-item">
									<span class="share-inner">小组编号：</span><input type="text" class="share-input" id="group-num"/>
								</div>
								<div class="admin-item">
									<span class="share-inner">服务中心： </span><input type="text" class="share-input" id="server-center"/>
								</div>
							</div>
							<button class="acquire" onclick="main_obj.group()">点击获取</button>
						</div>
					
					</div>
					
					<div class="wallet-top wallet-top-border" id="audit-group" style="display: none;">
						<div class="my-wallet">
							<div class="wallet-font">进入系统小组</div>
							<div class="admin-top">
								<div class="audit">审核中...</div>
							</div>
					
						</div>
					
					</div>
					
					<div class="wallet-top wallet-top-border" id="group-info" style="display: none;">
						<div class="my-wallet">
							<div class="wallet-font">我的小组</div>
							<div class="wallet-flex">
								<div class="money-flex number-border">
									<div class="sum" id="dis-group"></div>
									<div class="sum-yuan">小组编号</div>
								</div>
								<div class="money-flex">
									<div class="sum"><span id="dis-group-num"></span>号位置</div>
									<div class="sum-yuan">我的位置</div>
								</div>
							</div>
						</div>
					
					</div>
					
					<div class="wallet-top " style="display: none;" id="my-group">
						<div class="my-wallet">
							<div class="share-flex bottom-border" onclick="main_obj.my_share()">
								<div>我的小组分享人</div>
								<div><span class="iconfont icon-you right-color"></span></div>
							</div>
							<div class="share-flex" onclick="main_obj.my_serve()">
								<div>我的服务中心</div>
								<div><span class="iconfont icon-you right-color"></span></div>
							</div>
						</div>
					
					</div> -->

					<div class="wallet-top ">
						<div class="my-wallet">
							<a href="javascript:;" class="share-flex bottom-border" onclick="main_obj.share()">
								<div>我的分享</div>
								<div><span class="iconfont icon-you right-color"></span></div>
							</a>
							<!-- <a href="javascript:;" class="share-flex" onclick="main_obj.my_audit()">
								<div>我的资料审核</div>
								<div><span class="iconfont icon-you right-color"></span></div>
							</a> -->
							<a href="javascript:;" class="share-flex ywy" onclick="main_obj.my_order()">
								<div>订单提交</div>
								<div><span class="iconfont icon-you right-color"></span></div>
							</a>
							<a href="javascript:;" class="share-flex ywy" onclick="main_obj.orderList()">
								<div>订单列表</div>
								<div><span class="iconfont icon-you right-color"></span></div>
							</a>
						</div>

					</div>

					<div class="wallet-top ">
						<div class="my-wallet">
							<a href="company.html" class="share-flex bottom-border">
								<div>公司简介</div>
								<div><span class="iconfont icon-you right-color"></span></div>
							</a>
							<a href="liability.html" class="share-flex">
								<div>入职须知</div>
								<div><span class="iconfont icon-you right-color"></span></div>
							</a>
						</div>

					</div>

				</div>
			</div>
		</div>

		<div class="postion-foot">
			<ul class="bottom-nav">
				<li>
					<a href="../index/index.html">
						<img src="../../images/index-1.png" class="index-img" />
						<div>首页</div>
					</a>
				</li>
				<li>
					<a href="../website/website.html">
						<img src="../../images/site-1.png" class="site-img" />
						<div>网点</div>
					</a>

				</li>
				<li>
					<a href="../my/my.html">
						<img src="../../images/my.png" class="my-img" />
						<div class="active-color">个人中心</div>
					</a>

				</li>
			</ul>
		</div>
	</body>
	<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/weiUI/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/api_url.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/port_url.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var user_arr = JSON.parse(sessionStorage.getItem('users_info'));
		$(function() {
			if(user_arr.is_service == 0){
				$('.ywy').hide();
			}
			if(sessionStorage.getItem("users_info") != null) {
				main_obj.user_info();
			} else {
				$('#is_show_btn').show();
				$('.welcome').html('您好，欢迎来到海门通信');
				$('#apply-group').show();
			}
		})
		var share =
			'               <div class="share-pople">分享人</div>' +
			'				<div class="font-weight" id="share-name"></div>' +
			'				<div class="share-pople">分享人联系电话</div>' +
			'				<div class="font-weight" id="share-pnone"></div>';
		var my_serve_html =
			'               <div class="share-pople">我的服务中心账号</div>' +
			'				<div class="font-weight" id="serve-id">1001</div>' +
			'				<div class="copy-btn" onclick="copy_fn(\'serve-id\')">复制</div>' +
			'				<div class="share-pople">服务中心联系人</div>' +
			'				<div class="font-weight" id="serve-name"></div>' +
			'				<div class="share-pople">服务中心联系电话</div>' +
			'				<div class="font-weight" id="serve-phone"></div>';
		var group = 1;
		var share_name = '',
			share_phone = '',		
			serve_id = '',
			serve_name = '',
			serve_phone = '';
		 function copy_fn(code_name) {
			var txt = $('#' + code_name + '').text();
			Copy(txt);
		}
		// 复制微信号函数
		function Copy(str) {
			var save = function(e) {
				e.clipboardData.setData('text/plain', str);
				e.preventDefault();
			};
			document.addEventListener('copy', save);
			document.execCommand('copy');
			document.removeEventListener('copy', save);
			$.toast('复制成功', "text");
		}
		var main_obj = {
			//登录成功，之后填写用户信息
			user_info: function() {
				$.ajax({
					url: config_URL.api + URL.userInfo, //请求的url地址
					dataType: "json", //返回格式为json
					data: {
						access_token: '41ab23e7efb238797fe39cc30f6b21d3',
						user_token: user_arr.user_token,
						user_id: user_arr.id
					},
					type: "POST", //请求方式
					success: function(res) {
						console.log(res)
						var data = res.data;
						if(res.code == 0) {
							$('.welcome').html(data.name);
							$('#is_show_btn').hide();
							if(data.headimg == '') {
								$('.tacitly').attr('src', '../../images/header.png');
							} else {
								$('.tacitly').attr('src', '' + data.headimg);
							}
							if(data.is_service == 1) {
								$('.is-serves').html('代理商');
							} else if((data.is_service == 2)) {
								$('.is-serves').html('业务员');
							}
							$('#sum').html(data.moneyMy);
							if(data.is == 0) {
								$('#apply-group').show();
							} else if(data.is == 1) {
								$('#audit-group').show();
							} else {
								$('#group-info').show();
								$('#my-group').show();
								$('#dis-group').html(data.group.diskGroup);
								$('#dis-group-num').html(data.group.diskNum);
								
							}
							
							share_name = data.getinfo.name;
							share_phone = data.getinfo.phone;							
							serve_id = data.baodaninfo.username;
							serve_name = data.baodaninfo.name;
							serve_phone = data.baodaninfo.phone;
						} else{
							$.toast(res.msg, "text");
							window.location.href = '../login/login.html'
						}

					},
					error: function(rul) {
						console.log('网络出错')
					}
				});
			},
			my_share: function() {
				$.alert(share, "我的小组分享人");
				$('#share-name').html(share_name);
				$('#share-pnone').html(share_phone);
			},
			my_serve: function() {
				$.alert(my_serve_html, "我的服务中心");
				$('#serve-id').html(serve_id);
				$('#serve-name').html(serve_name);
				$('#serve-phone').html(serve_phone);				
			},
			login_fn: function() {
				location.href = '../login/login.html'
			},
			//编辑资料
			compile_fn: function() {
				if(sessionStorage.getItem("users_info") != null) {
					location.href = 'compile_info.html'
				} else {
					location.href = '../login/login.html'
				}
			},
			//现金明细
			money_detail: function() {
				if(sessionStorage.getItem("users_info") != null) {
					location.href = '../wallet/cash_details.html'
				} else {
					location.href = '../login/login.html'
				}
			},
			//收入记录
			sr_detail: function() {
				if(sessionStorage.getItem("users_info") != null) {
					location.href = '../wallet/sr_details.html'
				} else {
					location.href = '../login/login.html'
				}
			},
			//提现
			withdraw: function() {
				if(sessionStorage.getItem("users_info") != null) {
					//location.href = '../wallet/mention_money.html'
					$.alert('<div class="share-pople"></div>', '暂未开通');
				} else {
					location.href = '../login/login.html'
				}
			},
			//提现记录
			withdraw_record: function() {
				if(sessionStorage.getItem("users_info") != null) {
					location.href = '../wallet/withdraw_record.html'
				} else {
					location.href = '../login/login.html'
				}
			},
			//获取服务中心
			get_serve_center: function() {
				$.ajax({
					url: config_URL.api + URL.getService, //请求的url地址
					dataType: "json", //返回格式为json
					data: {
						access_token: '41ab23e7efb238797fe39cc30f6b21d3',
						user_id:user_arr.id
					},
					type: "POST", //请求方式
					success: function(res) {
						console.log(res);
						var data = res.data;
						if(res.code == 0) {
							$('#share-pople').val(data.share);
							$('#group-num').val(data.group);
							$('#server-center').val(data.service);
							$('.acquire').html('提交申请');
							group++;							
						} else {
							$.toast(res.msg, "text");
						}

					},
					error: function(rul) {
						console.log('网络出错')
					}
				});
			},
			//申请进入小组
			apply_group:function(){
				$.ajax({
					url: config_URL.api + URL.applyAdd, //请求的url地址
					dataType: "json", //返回格式为json
					data: {
						access_token: '41ab23e7efb238797fe39cc30f6b21d3',
						user_id:user_arr.id,
						share:$('#share-pople').val(),
						baodan:$('#server-center').val(),
						group:$('#group-num').val()
					},
					type: "POST", //请求方式
					success: function(res) {
						console.log(res);
						var data = res.data;
						if(res.code == 0) {
							$.toast('提交成功！', "text");								
							main_obj.user_info();
						} else {
							$.toast(res.msg, "text");
						}

					},
					error: function(rul) {
						console.log('网络出错')
					}
				});
			},
			//进入系统小组
			group: function() {				
				if(sessionStorage.getItem("users_info") != null) {
					if(group>1){
						main_obj.apply_group();
					}else{
						main_obj.get_serve_center();
					}
					
				} else {
					location.href = '../login/login.html'
				}
			},
			//我的分享
			share: function() {
				if(sessionStorage.getItem("users_info") != null) {
					location.href = 'share.html'
				} else {
					location.href = '../login/login.html'
				}
			},
			//我的资料审核
			my_audit: function() {
				if(sessionStorage.getItem("users_info") != null) {
					location.href='../index/material_submit.html'
				} else {
					location.href = '../login/login.html'
				}
			},

			//订单列表
			orderList: function() {
				if(sessionStorage.getItem("users_info") != null) {
					location.href='../wallet/order_list.html'
				} else {
					location.href = '../login/login.html'
				}
			},
			//订单提交
			my_order: function() {
				if(sessionStorage.getItem("users_info") != null) {
					location.href='../index/order_submit.html'
				} else {
					location.href = '../login/login.html'
				}
			}

		}
	</script>

</html>